#ifndef window_h__
#define window_h__
#include <windows.h>

#define WINDOWCLASSNAME "GECKO"

namespace gecko
{

extern HWND g_hwnd;
extern HINSTANCE g_hinstance;

class IInputManager;

// Wrapper class for setting up and running Win32 windows.
class Window
{
public:
	// constructor
	Window();

	// destructor
	virtual ~Window();

	// Create the window.
	void Initialise(int width, int height, int bpp, bool fullscreen/*, InputMgr* pInputMgr*/);

	// Get window width.
	int GetWidth();

	// Get window height.
	int GetHeight();

	// Get window position.
	void GetWindowPosition(int& x, int& y);

	// Run the window message loop.
	bool Run();

	// Destroy the framework.
	bool Destroy();

	// Toggle cursor visibility.
	void ToggleCursor(bool show);

	// Force the framework to shutdown.
	void ForceCloseAndExit();

	// Display a standard windows message box.
	void ShowMessageBox(const char* msg);

	// Get window handle.
	HWND GetWindowHandle();

	// Get HINSTANCE of window.
	HINSTANCE GetHInstance(void);

	// set the input manager (required so that losing/gaining focus can unacquire/acquire devices)
	void SetInputMananger(IInputManager * inputManager);

private:
	// Create a fullscreen window
	bool CreateFullScreenWindow();

	// Create a standard window
	bool CreateStandardWindow();

	// Initiate a change of resolution
	bool ChangeDisplayMode();

	// Post a close window message
	void CloseWindow();

	// Static window proc function for message pump
	static LRESULT CALLBACK StaticWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );

	// WindowProc
	LRESULT CALLBACK WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );

private:
	int m_width;
	int m_height;
	int m_bpp;
	bool m_fullScreen;
	bool m_fullscreenEntered;
	bool m_active;
	char m_windowTitle[64];
	HWND m_hWnd;
	HINSTANCE m_hInstance;
	IInputManager * m_inputManager;
};

}

#endif // window_win32_h__
